package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.LevelMenu;
import com.zygh.interactiveplatform.module.service.LevelMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-02-02
 */
@RestController
@RequestMapping("/level-menu")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_LEVELMENU})
public class LevelMenuController {
    @Resource
    private LevelMenuService levelMenuService;

    @ApiOperation(value = "新增设备管理二级菜单", notes = "新增设备管理二级菜单")
    @PostMapping("addLevelMenue")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_LEVELMENU, content = "新增设备管理二级菜单")
    public ResponseDTO addLevelMenue(@RequestBody @Valid LevelMenu levelMenu) {
        return levelMenuService.addLevelMenu(levelMenu);
    }
    @ApiOperation(value = "修改设备管理二级菜单", notes = "修改设备管理二级菜单")
    @PostMapping("updateLevelMenu")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_LEVELMENU, content = "修改设备管理二级菜单")
    public ResponseDTO updateLevelMenu(@RequestBody @Valid LevelMenu levelMenu) {
        return levelMenuService.updateLevelMenu(levelMenu);
    }
    @ApiOperation(value = "删除设备管理二级菜单", notes = "删除设备管理二级菜单")
    @PostMapping("deleteLevelMenu")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_LEVELMENU, content = "删除设备管理二级菜单")
    public ResponseDTO deleteLevelMenu(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return levelMenuService.deleteLevelMenu(new_id);
    }
    @ApiOperation(value = "查询所有设备管理二级菜单", notes = "查询所有设备管理二级菜单")
    @GetMapping("findLevelMenuAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_LEVELMENU, content = "查询所有设备管理二级菜单")
    public ResponseDTO findLevelMenuAll(Integer current, Integer size) {
        return levelMenuService.findLevelMenuAll(current,size);
    }
}
